package com.vne.skyemart.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.vne.skyemart.service.PermissionService;
import com.vne.skyemart.service.UserService;
import com.vne.skyemart.util.CommonUtils;

@Controller
@SessionAttributes
@RequestMapping("/account")
public class AccountController {
	
	@Autowired
	private PermissionService permissionService;
	@Autowired
	private UserService userService;
	
	
	@RequestMapping(value = "/permissions", method = RequestMethod.GET)
	public String getAllPermission(Model model) {
		model.addAttribute("permissions",  permissionService.getAllPermissions());

		return "permissionList";
	}
	
	@RequestMapping(value = "/userlist", method = RequestMethod.GET)
	public String getAllUser(Model model) {
		model.addAttribute("userList", userService.getAllUserSummary());
		model.addAttribute("numberOnline", CommonUtils.getAllUserOnline().size());
		return "admin.user.list";
	}
}
